<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
	<%@ include file="/base/jsp/include.jsp"%>
	<script type="text/javascripthttp://dns.www.net.cn/static/images/loading.gif">
	</script>
  </head>
  <body>
    <form id="form" method="post">
        <input name="id" class="mini-hidden" />
        <fieldset style="border:solid 1px #aaa;padding:10px;">
            <legend >基本信息</legend>
            <div style="padding:5px;">
            <table>
            	<tr>
                    <td style="width:70px;">排序值：</td>
                    <td style="width:150px;">
                    	<input name="orderValue" id="orderValue" class="mini-textbox" required="true" vtype="maxLength:50" emptyText="排序值"/>
                    </td>
                </tr>
                <tr>
                    <td style="width:70px;">显示名称：</td>
                    <td style="width:150px;">
                    	<input name="name" id="name" class="mini-textbox" required="true" vtype="maxLength:100" emptyText="显示名称"/>
                    </td>
                </tr>
            </table>            
         </div>
        </fieldset>
        
        <div style="text-align:center;padding:10px;">
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
    <script type="text/javascript">
    	var id = '';
        mini.parse();
        var form = new mini.Form("form");
        function SaveData() {
            var o = form.getData(true);     
            form.validate();
            if (form.isValid() == false) return;
            var json = mini.encode(o);
            $.ajax({
                url: "saveBCategory.do",
                type: 'post',
                data:  $.evalJSON(json),
                cache: false,
                success: function (text) {
                    CloseWindow("save");
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }

        //标准方法接口定义
        function SetData(data) {
            if (data.action == "edit") {
            	$('#pwdTr').hide();
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                $.ajax({
                    url: "findByIdBCategory.do?id=" + data.id,
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text,true);
                        form.setData(o);
                        form.setChanged(false);
                        id = o.id;
                      
                        //var c = mini.get('name');
                        //c.setReadOnly(true);     //只读
                		//c.setIsValid(true);      //去除错误提示
                		//c.addCls("asLabel");     //增加asLabel外观
                    }
                });
            }
        }

        function GetData() {
            var o = form.getData(true);
            return o;
        }
        function CloseWindow(action) {
            if (action == "cancel" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                	SaveData();
                	return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk(e) {
            SaveData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
        
    </script>	
  </body>
</html>
